<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>${site.title!''}</title>
    <meta name="description" content="${site.description!''}">
    <meta name="keywords" content="${site.keywords!''}">
    <style>
        /* CSS Reset and Basic Setup */
        :root {
            --primary-blue: #2979ff;
            --dark-blue: #0d47a1;
            --field-item-bg: #E8EEFD;
            --field-item-border: #D2DFFF;
            --text-primary: #333;
            --text-secondary: #666;
            --text-light: #999;
            --border-color: #e0e0e0;
            --background-grey: #f5f5f5;
        }

        body, h1, h2, h3, p, ul, li, a, button {
            margin: 0;
            padding: 0;
            font-family: "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
            text-decoration: none;
            color: inherit;
            box-sizing: border-box;
        }

        li {
            list-style: none;
        }

        body {
            background-color: var(--background-grey);
            color: var(--text-primary);
        }

        .container {
            width: 1200px;
            margin: 0 auto;
        }

        /* Generic Section Header */
        .section-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding-bottom: 15px;
            margin-bottom: 20px;
            border-bottom: 1px solid var(--border-color);
        }

        .section-header h2 {
            display: flex;
            align-items: center;
            gap: 15px;
            font-size: 20px;
            color: var(--text-primary);
            font-weight: 500;
        }

        .section-header h2 .icon {
            width: 40px;
            height: 40px;
            border-radius: 8px;
            background-color: #f0f0f0;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .section-header h2 .icon img {
             height: 24px;
        }

        .section-header .more {
            font-size: 14px;
            color: var(--text-light);
        }

        .section-header .more:hover {
            color: var(--primary-blue);
        }

        /* Header */
        header {
            background-color: #fff;
            box-shadow: 0 2px 4px rgba(0,0,0,0.05);
        }

        .top-bar {
            background-color: #fff;
            padding: 8px 0;
            font-size: 13px;
            color: var(--text-secondary);
            border-bottom: 1px solid #f0f0f0;
        }

        .top-bar .container, .top-bar-left, .top-bar-right {
            display: flex;
            align-items: center;
        }
        .top-bar .container {
            justify-content: space-between;
        }

        .top-bar-left .logo {
            height: 28px;
            margin-right: 15px;
        }

        .top-bar-left .divider {
            color: var(--border-color);
            margin: 0 12px;
        }

        .top-bar a { margin: 0 10px; transition: color 0.2s; }
        .top-bar a:hover { color: var(--primary-blue); }

        .top-bar-right .social-icons img {
            height: 20px;
            margin-left: 15px;
            vertical-align: middle;
        }

        .top-bar-right .project-entry {
            background-color: var(--primary-blue);
            color: #fff;
            padding: 8px 18px;
            border-radius: 4px;
            margin-left: 20px;
            font-size: 14px;
            transition: background-color 0.2s;
        }
        .top-bar-right .project-entry:hover { background-color: var(--dark-blue); }

        .main-nav .container { display: flex; justify-content: flex-start; }
        .main-nav ul { display: flex; }
        .main-nav ul li a {
            display: block;
            padding: 18px 25px;
            font-size: 16px;
            font-weight: 500;
            color: var(--text-primary);
            border-bottom: 3px solid transparent;
        }
        .main-nav ul li a:hover, .main-nav ul li a.active {
            color: var(--primary-blue);
            border-bottom-color: var(--primary-blue);
        }

        /* Hero Banner */
        .hero-banner {
            height: 600px;
            background: url('./img/ed3943434d0d99e5f94912184c243fba_.png') no-repeat center center;
            background-size: contain;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            color: #fff;
            text-align: center;
        }
        .hero-banner h1 { font-size: 48px; font-weight: bold; text-shadow: 0px 2px 6px rgba(0,0,0,0.5); }
        .hero-banner p { font-size: 24px; margin: 15px 0 25px 0; font-weight: 300; text-shadow: 0px 1px 4px rgba(0,0,0,0.5); }
        .hero-banner .organizers { display: flex; align-items: center; font-size: 16px; }
        .hero-banner .organizers img { height: 40px; margin: 0 15px; background-color: rgba(255, 255, 255, 0.9); border-radius: 5px; padding: 5px; }

        /* Main Content */
        main { padding: 30px 0; }
        .card { background-color: #fff; padding: 20px; margin-bottom: 20px; }
        .content-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 10px; }

        /* REVISED: Generic class for sections with image on left, list on right */
        .list-section-image {
            display: flex;
            gap: 25px;
            align-items: center;
        }
        .list-section-image img {
            width: 300px;
            height: 180px;
            object-fit: cover;
            flex-shrink: 0;
            border-radius: 4px;
        }
        .list-section-image ul { flex-grow: 1; }
        .list-section-image ul li {
            /* REVISED: Flex layout for Title + Date */
            display: flex;
            align-items: center;
            padding: 8px 0;
            font-size: 14px;
            border-bottom: 1px dotted #ccc;
        }
        .list-section-image ul li::before {
            /* REVISED: Removed hyphen */
            content: '';
            margin: 0;
        }
        .list-section-image ul li:first-child { padding-top: 0; }
        .list-section-image ul li:last-child { border-bottom: none; }
        .list-section-image ul li a {
             flex: 1;
             white-space: nowrap;
             overflow: hidden;
             text-overflow: ellipsis;
             margin-right: 15px;
        }
        .list-section-image ul li a:hover { color: var(--primary-blue); }
        .list-section-image .date {
            color: var(--text-light);
            flex-shrink: 0;
        }

        /* Announcements Section */
        .simple-list-section ul li {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px 0 10px 15px;
            font-size: 14px;
            border-bottom: 1px dotted #ccc;
            background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="6" height="6"><circle cx="3" cy="3" r="3" fill="%23999"/></svg>') no-repeat left 8px;
        }
        .simple-list-section ul li:last-child { border-bottom: none; }
        .simple-list-section ul li a { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 550px; }
        .simple-list-section ul li a:hover { color: var(--primary-blue); }
        .simple-list-section ul li .date { color: var(--text-light); }

        /* Quick Actions */
        .quick-actions button { background-color: var(--dark-blue); color: #fff; border: none; padding: 12px; font-size: 16px; border-radius: 4px; cursor: pointer; transition: background-color 0.2s; }
        .quick-actions button:hover { background-color: var(--primary-blue); }

        /* Carousel Sections */
        .carousel-section { background-color: #fff; padding: 20px; margin-bottom: 20px; }
        .carousel-container { position: relative; }
        .carousel-wrapper { overflow: hidden; }
        .carousel { display: flex; transition: transform 0.5s ease; }
        .carousel-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; background-color: #e9e9e9; color: var(--text-secondary); border: none; border-radius: 50%; cursor: pointer; font-size: 20px; font-weight: bold; z-index: 10; display: flex; align-items: center; justify-content: center; transition: background-color 0.2s, color 0.2s; }
        .carousel-nav:hover { background-color: var(--primary-blue); color: #fff; }
        .carousel-nav.prev { left: -50px; }
        .carousel-nav.next { right: -50px; }

        .app-fields .carousel { gap: 15px; }
        .app-fields .field-item {
            flex: 0 0 180px;
            padding: 20px;
            background-color: var(--primary-blue);
            border: 1px solid var(--primary-blue);
            color: #fff;
            border-radius: 4px;
            text-align: center;
            font-size: 16px;
            font-weight: 500;
            cursor: pointer;
            transition: opacity 0.2s;
        }
        .app-fields .field-item:hover { opacity: 0.8; }

        .meetings-section .carousel { gap: 20px; }
        .meetings-section .meeting-item { flex: 0 0 calc((1160px - 60px) / 4); text-align: center; }
        .meetings-section .meeting-item img { width: 100%; height: 160px; object-fit: cover; border: 1px solid var(--border-color); border-radius: 4px; display: block; }
        .meetings-section .meeting-item p { margin-top: 10px; font-size: 14px; color: var(--text-secondary); }

        /* Problem Collection Section Styling */
        .problem-collection-section .content { display: flex; justify-content: space-between; align-items: center; }
        .problem-collection-section ul { flex-grow: 1; }
        .problem-collection-section ul li { display: flex; align-items: center; padding: 10px 0; font-size: 14px; border-bottom: 1px dotted #ccc; }
        .problem-collection-section ul li:last-child { border-bottom: none; }
        .problem-collection-section ul li::before { content: '·'; font-size: 24px; line-height: 1; margin-right: 10px; color: var(--text-secondary); }
        .problem-collection-section ul li a:hover { color: var(--primary-blue); }

        .problem-collection-link { display: flex; align-items: center; gap: 15px; padding-left: 30px; border-left: 1px solid var(--border-color); margin-left: 20px; cursor: pointer; }
        .problem-collection-link .icon-wrapper {
            width: 60px;
            height: 60px;
            background-color: var(--dark-blue);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 36px;
            font-weight: bold;
            flex-shrink: 0;
        }
        .problem-collection-link .text { font-size: 16px; color: var(--dark-blue); font-weight: 500; }
        .problem-collection-link .more-dots { font-size: 24px; color: var(--text-light); font-weight: bold; }

        /* Partners Section */
        .partners-section .partners-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
        .partners-section .partner-item { height: 60px; background-color: var(--primary-blue); border-radius: 4px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 20px; font-weight: bold; }

        /* Footer */
        footer { background-color: #3a3a3a; color: #ccc; padding: 40px 0; margin-top: 20px; font-size: 13px; }
        .footer-content { display: flex; justify-content: space-between; align-items: center; }
        .footer-logo img { height: 60px; opacity: 0.6; }
        .footer-info { text-align: right; color: #999; }
        .footer-info p { margin-bottom: 8px; }
        .footer-info p:last-child { margin-bottom: 0; }
    </style>
</head>
<body>

    <header>
        <div class="top-bar">
            <div class="container">
                <div class="top-bar-left">
                    <#if site.logo??>
                        <img src="${site.logo}" alt="${site.name!''} Logo" class="logo">
                    </#if>
                    <#if site.secondaryLogo??>
                        <img src="${site.secondaryLogo}" alt="Secondary Logo" class="logo">
                    </#if>
                    <span class="divider">|</span>
                    <#if topMenus?? && topMenus?size gt 0>
                        <#list topMenus as menu>
                            <a href="${menu.url!''}">${menu.name!''}</a>
                        </#list>
                    <#else>
                        <a href="/">首页</a><a href="/news">新闻</a><a href="/blog">博览</a><a href="/journal">期刊</a><a href="/pattern">模式识别</a><a href="/about">关于</a>
                    </#if>
                </div>
                <div class="top-bar-right">
                    <a href="/login">登录</a><a href="/register">注册</a>
                    <div class="social-icons">
                         <img src="" alt="Weibo">
                         <img src="" alt="QR Code">
                    </div>
                    <a href="/project" class="project-entry">项目入口</a>
                </div>
            </div>
        </div>
        <nav class="main-nav">
            <div class="container">
                <ul>
                    <#if mainMenus?? && mainMenus?size gt 0>
                        <#list mainMenus as menu>
                            <li><a href="${menu.url!''}" <#if menu.active?? && menu.active>class="active"</#if>>${menu.name!''}</a></li>
                        </#list>
                    <#else>
                        <li><a href="/news" class="active">新闻</a></li>
                        <li><a href="/announcements">公告</a></li>
                        <li><a href="/activities">活动</a></li>
                        <li><a href="/discussions">讨论</a></li>
                        <li><a href="/problems">问题征集</a></li>
                        <li><a href="/help">帮助文档</a></li>
                    </#if>
                </ul>
            </div>
        </nav>
    </header>

    <div class="hero-banner" <#if bannerImage??>style="background-image: url('${bannerImage}');"</#if>>
        <#if bannerTitle??>
            <h1>${bannerTitle}</h1>
        </#if>
        <#if bannerSubtitle??>
            <p>${bannerSubtitle}</p>
        </#if>
        <div class="organizers">
            <#if organizers?? && organizers?size gt 0>
                <#list organizers as organizer>
                    <#if organizer.logo??>
                        <img src="${organizer.logo}" alt="${organizer.name!''}">
                    </#if>
                </#list>
            </#if>
        </div>
    </div>

    <main class="container">
        <section class="card news-section">
            <header class="section-header">
                <h2>
                    <span class="icon">
                        <img src="">
                    </span>
                    新闻
                </h2>
                <a href="/news" class="more">更多 >></a>
            </header>
            <div class="list-section-image">
                <#if newsImage??>
                    <img src="${newsImage}" alt="News Image">
                <#else>
                    <img src="https://via.placeholder.com/300x180/A9B4C4/FFFFFF?text=News" alt="News Image">
                </#if>
                <ul>
                    <#if newsList?? && newsList?size gt 0>
                        <#list newsList as news>
                            <li>
                                <a href="/news/${news.id!''}" title="${news.title!''}">${news.title!''}</a>
                                <span class="date">${news.publishDate?string('yyyy-MM-dd')}</span>
                            </li>
                        </#list>
                    <#else>
                        <li><a href="#">暂无新闻</a><span class="date">--</span></li>
                    </#if>
                </ul>
            </div>
        </section>

        <div class="content-grid">
            <div class="grid-left">
                <section class="card announcements-section simple-list-section">
                    <header class="section-header">
                        <h2>
                            <span class="icon">
                                <img src="">
                            </span>
                            公告
                        </h2>
                        <a href="/announcements" class="more">更多 >></a>
                    </header>
                    <ul>
                        <#if announcementsList?? && announcementsList?size gt 0>
                            <#list announcementsList as announcement>
                                <li>
                                    <a href="/announcements/${announcement.id!''}" title="${announcement.title!''}">${announcement.title!''}</a>
                                    <span class="date">${announcement.publishDate?string('yyyy-MM-dd')}</span>
                                </li>
                            </#list>
                        <#else>
                            <li><a href="#">暂无公告</a><span class="date">--</span></li>
                        </#if>
                    </ul>
                </section>
            </div>
            <div class="grid-right">
                <section class="card quick-actions">
                    <header class="section-header"><h2>快捷操作</h2></header>
                    <div class="content-grid" style="grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 0;">
                        <#if quickActions?? && quickActions?size gt 0>
                            <#list quickActions as action>
                                <button onclick="location.href='${action.url!''}';">${action.name!''}</button>
                            </#list>
                        <#else>
                            <button onclick="location.href='/project';">项目</button>
                            <button onclick="location.href='/news';">新闻</button>
                            <button onclick="location.href='/announcements';">公告</button>
                            <button onclick="location.href='/activities';">活动</button>
                            <button onclick="location.href='/discussions';">讨论</button>
                            <button onclick="location.href='/problems';">问题征集</button>
                        </#if>
                    </div>
                </section>
            </div>
        </div>

        <section class="carousel-section app-fields">
            <header class="section-header"><h2>应用领域</h2></header>
            <div class="carousel-container" id="app-fields-carousel">
                <button class="carousel-nav prev">&lt;</button>
                <div class="carousel-wrapper">
                    <div class="carousel">
                        <#if applicationFields?? && applicationFields?size gt 0>
                            <#list applicationFields as field>
                                <div class="field-item" onclick="location.href='${field.url!''}';">${field.name!''}</div>
                            </#list>
                        <#else>
                            <div class="field-item">EDA</div>
                            <div class="field-item">军事</div>
                            <div class="field-item">医疗</div>
                            <div class="field-item">数学</div>
                            <div class="field-item">人工智能</div>
                            <div class="field-item">科普教育</div>
                        </#if>
                    </div>
                </div>
                <button class="carousel-nav next">&gt;</button>
            </div>
        </section>

        <section class="carousel-section meetings-section">
            <header class="section-header">
                <h2>会议</h2>
                <a href="/meetings" class="more">更多 >></a>
            </header>
            <div class="carousel-container" id="meetings-carousel">
                <button class="carousel-nav prev">&lt;</button>
                <div class="carousel-wrapper">
                    <div class="carousel">
                        <#if meetingsList?? && meetingsList?size gt 0>
                            <#list meetingsList as meeting>
                                <div class="meeting-item">
                                    <img src="${meeting.image!'https://via.placeholder.com/275x160/cccccc/000000?text=Conference'}" alt="${meeting.title!''}">
                                    <p>${meeting.title!''}</p>
                                </div>
                            </#list>
                        <#else>
                            <div class="meeting-item">
                                <img src="https://via.placeholder.com/275x160/cccccc/000000?text=Conference+1" alt="Meeting 1">
                                <p>中国运筹学会第十一届理事会第六次...</p>
                            </div>
                            <div class="meeting-item">
                                <img src="https://via.placeholder.com/275x160/cccccc/000000?text=Conference+2" alt="Meeting 2">
                                <p>中国运筹学会第十一届理事会第六次...</p>
                            </div>
                            <div class="meeting-item">
                                <img src="https://via.placeholder.com/275x160/cccccc/000000?text=Conference+3" alt="Meeting 3">
                                <p>中国运筹学会第十一届理事会第六次...</p>
                            </div>
                            <div class="meeting-item">
                                <img src="https://via.placeholder.com/275x160/cccccc/000000?text=Conference+4" alt="Meeting 4">
                                <p>中国运筹学会第十一届理事会第六次...</p>
                            </div>
                        </#if>
                    </div>
                </div>
                <button class="carousel-nav next">&gt;</button>
            </div>
        </section>

        <section class="card activity-section">
            <header class="section-header">
                <h2>
                    <span class="icon">
                        <img src="">
                    </span>
                    活动
                </h2>
                <a href="/activities" class="more">更多 >></a>
            </header>
            <div class="list-section-image">
                <#if activityImage??>
                    <img src="${activityImage}" alt="Activity Image">
                <#else>
                    <img src="https://via.placeholder.com/300x180/A9B4C4/FFFFFF?text=Activity" alt="Activity Image">
                </#if>
                <ul>
                    <#if activitiesList?? && activitiesList?size gt 0>
                        <#list activitiesList as activity>
                            <li>
                                <a href="/activities/${activity.id!''}" title="${activity.title!''}">${activity.title!''}</a>
                                <span class="date">${activity.publishDate?string('yyyy-MM-dd')}</span>
                            </li>
                        </#list>
                    <#else>
                        <li><a href="#">暂无活动</a><span class="date">--</span></li>
                    </#if>
                </ul>
            </div>
        </section>

        <section class="card discussion-section">
            <header class="section-header">
                <h2>
                    <span class="icon">
                        <img src="">
                    </span>
                    讨论
                </h2>
                <a href="/discussions" class="more">更多 >></a>
            </header>
            <div class="list-section-image">
                <#if discussionImage??>
                    <img src="${discussionImage}" alt="Discussion Image">
                <#else>
                    <img src="https://via.placeholder.com/300x180/A9B4C4/FFFFFF?text=Discussion" alt="Discussion Image">
                </#if>
                <ul>
                    <#if discussionsList?? && discussionsList?size gt 0>
                        <#list discussionsList as discussion>
                            <li>
                                <a href="/discussions/${discussion.id!''}" title="${discussion.title!''}">${discussion.title!''}</a>
                                <span class="date">${discussion.publishDate?string('yyyy-MM-dd')}</span>
                            </li>
                        </#list>
                    <#else>
                        <li><a href="#">暂无讨论</a><span class="date">--</span></li>
                    </#if>
                </ul>
            </div>
        </section>

        <section class="card problem-collection-section">
            <header class="section-header">
                <h2>问题征集</h2>
                <a href="/problems" class="more">更多 >></a>
            </header>
            <div class="content">
                <ul>
                    <#if problemsList?? && problemsList?size gt 0>
                        <#list problemsList as problem>
                            <li><a href="/problems/${problem.id!''}">${problem.title!''}</a></li>
                        </#list>
                    <#else>
                        <li><a href="#">暂无问题征集</a></li>
                    </#if>
                </ul>
                <div class="problem-collection-link" onclick="location.href='/problems';">
                    <div class="icon-wrapper">?</div>
                    <div class="text">问题征集</div>
                    <div class="more-dots">...</div>
                </div>
            </div>
        </section>

        <section class="card partners-section">
            <header class="section-header">
                <h2>
                    <span class="icon">
                        <img src="">
                    </span>
                    合作单位
                </h2>
            </header>
            <div class="partners-grid">
                <#if partnersList?? && partnersList?size gt 0>
                    <#list partnersList as partner>
                        <div class="partner-item" <#if partner.url??>onclick="location.href='${partner.url}';"</#if>>
                            ${partner.name!''}
                        </div>
                    </#list>
                <#else>
                    <div class="partner-item">SPARK易派</div>
                    <div class="partner-item">SPARK易派</div>
                    <div class="partner-item">SPARK易派</div>
                    <div class="partner-item">SPARK易派</div>
                    <div class="partner-item">SPARK易派</div>
                    <div class="partner-item">SPARK易派</div>
                    <div class="partner-item">SPARK易派</div>
                </#if>
            </div>
        </section>
    </main>

    <footer>
        <div class="container footer-content">
            <div class="footer-logo">
                <#if site.footerLogo??>
                    <img src="${site.footerLogo}" alt="Footer Logo">
                <#else>
                    <img src="https://www.orip.com.cn/ASAP/images/nlogob.png" alt="Footer Logo">
                </#if>
            </div>
            <div class="footer-info">
                <#if site.copyright??>
                    <p>${site.copyright}</p>
                <#else>
                    <p>版权所有：中国运筹学会</p>
                </#if>
                <#if site.technicalSupport??>
                    <p>${site.technicalSupport}</p>
                <#else>
                    <p>技术支持：北京博纳讯动科技有限公司</p>
                </#if>
                <#if site.icp??>
                    <p>${site.icp}</p>
                <#else>
                    <p>京ICP备05002817号-1</p>
                </#if>
            </div>
        </div>
    </footer>

    <script>
        // 轮播功能
        function initCarousel(containerId) {
            const container = document.getElementById(containerId);
            if (!container) return;

            const carousel = container.querySelector('.carousel');
            const prevBtn = container.querySelector('.carousel-nav.prev');
            const nextBtn = container.querySelector('.carousel-nav.next');

            if (!carousel || !prevBtn || !nextBtn) return;

            const items = carousel.children;
            const itemWidth = items[0] ? items[0].offsetWidth : 0;
            const gap = 15; // 间距
            const visibleItems = Math.floor(carousel.parentElement.offsetWidth / (itemWidth + gap));
            const maxScroll = Math.max(0, (items.length - visibleItems) * (itemWidth + gap));

            let currentScroll = 0;

            function updateCarousel() {
                carousel.style.transform = `translateX(-${currentScroll}px)`;
                prevBtn.style.display = currentScroll > 0 ? 'flex' : 'none';
                nextBtn.style.display = currentScroll < maxScroll ? 'flex' : 'none';
            }

            prevBtn.addEventListener('click', () => {
                currentScroll = Math.max(0, currentScroll - (itemWidth + gap));
                updateCarousel();
            });

            nextBtn.addEventListener('click', () => {
                currentScroll = Math.min(maxScroll, currentScroll + (itemWidth + gap));
                updateCarousel();
            });

            updateCarousel();
        }

        // 页面加载完成后初始化轮播
        document.addEventListener('DOMContentLoaded', function() {
            initCarousel('app-fields-carousel');
            initCarousel('meetings-carousel');
        });
    </script>
</body>
</html>
